from multiprocessing import Process
import time
from os import getcwd, environ
from Config_Apply import Config_Apply, pv_publish

PATH = getcwd()

environ["EPICS_CAS_SERVER_PORT"] = "5064"
environ["EPICS_CA_ADDR_LIST"] = "127.0.0.1:5064 192.168.6.2:5064 192.168.6.22:5064 192.168.6.41:5064 192.168.6.42:5064 192.168.6.51:5064 192.168.6.52:5064 192.168.6.29:5064 192.168.185.22:5064 192.168.185.22:5066 192.168.185.22:5068 192.168.185.22:5070 192.168.185.22:5072 192.168.185.22:5074 192.168.185.22:5076 192.168.185.22:5078 192.168.185.22:5080 192.168.185.22:5082 192.168.185.22:5084 192.168.185.22:5086 192.168.185.22:5088 192.168.185.22:5090 192.168.185.22:5092 192.168.185.22:5094 192.168.185.22:5096 192.168.185.22:5098 192.168.185.22:5100 192.168.185.22:5102"
environ["EPICS_CA_AUTO_ADDR_LIST"] = "no"

# load_mode_list = ["BPS"]
load_mode_list = ["MPS_MW","MPS_LFC","BPS"]


def load_mode():

    for name in load_mode_list:
        time.sleep(1)
        P = Process(target=Config_Apply, args=(name,))
        P.start()

def Total():
    print(str(time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time())))+"启动程序 ")
    P = Process(target=pv_publish, args=(load_mode_list,))
    P.start()
    load_mode()


if __name__ == "__main__":
    Total()
